package com.jm.weibo.ui;


import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;

import com.jm.weibo.logic.IWeiboActivity;

/**
 * 主要负责Tab间的切换
 * @author 焦明
 * 2010-4-24 9:57
 *
 */
public class HomeActivity extends TabActivity implements IWeiboActivity{
	public View msgTitle;//信息头部按钮
	 
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
	}
	 
	public void init() {
		// TODO Auto-generated method stub
		
	}
	 
	public void refresh(Object... param) {
		// TODO Auto-generated method stub
		
	}
	protected void onCreate(Bundle savedInstanceState) {
		 
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		//各子页的加载
		this.setContentView(R.layout.maintabs);
		msgTitle=this.findViewById(R.id.msg_title);
		//对消息的处理
		Button btcomment=(Button)this.findViewById(R.id.bt_group_middle);
		//评论
		btcomment.setOnClickListener(new OnClickListener(){
 	                 
					public void onClick(View v) {
					   Toast.makeText(HomeActivity.this, "对我的评论", Toast.LENGTH_SHORT).show();
					   MessageActivity.process.setVisibility(View.VISIBLE);
					   MessageActivity.getAllComment();	
					}
		});
		
		//私信
		Button btdirectmess=(Button)this.findViewById(R.id.bt_group_right);
		btdirectmess.setOnClickListener(new OnClickListener(){
              
			public void onClick(View v) {
				Toast.makeText(HomeActivity.this, "我的私信", Toast.LENGTH_SHORT).show();
				MessageActivity.process.setVisibility(View.VISIBLE);
			    MessageActivity.getAlldirectMessage();	
             }
	
		});
		
		//提示我的
		Button btnMentionMe = (Button) this.findViewById(R.id.bt_group_left);
		btnMentionMe.setOnClickListener(new OnClickListener(){
            
			public void onClick(View v) {
				Toast.makeText(HomeActivity.this, "提到我的", Toast.LENGTH_SHORT).show();
				MessageActivity.process.setVisibility(View.VISIBLE);
			    MessageActivity.getAlldirectMessage();	
             }
	
		});
		
		//完成各子页集成
		final TabHost th=this.getTabHost();
		
		th.addTab(th.newTabSpec("TAB_HOME")
		   .setIndicator("TAB_HOME")
		   .setContent(new Intent(this,MyListActivity.class))
		  );
		th.addTab(th.newTabSpec("TAB_MSG")
				   .setIndicator("TAB_MSG")
				   //MessageActivity.................................
				   .setContent(new Intent(this,MessageActivity.class))
				  );
		th.addTab(th.newTabSpec("TAB_USER_INFO")
				   .setIndicator("TAB_USER_INFO")
				   .setContent(new Intent(this,UserInfoActivity.class))
				  );
		th.addTab(th.newTabSpec("TAB_SEARCH")
				   .setIndicator("TAB_SEARCH")
				   .setContent(new Intent(this,SearchActivity.class))
				  );
		th.addTab(th.newTabSpec("TAB_MORE")
				   .setIndicator("TAB_MORE")
				   .setContent(new Intent(this,MoreActivity.class))
				  );
		RadioGroup mainGroup=(RadioGroup)this.findViewById(R.id.main_radio);
		mainGroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
		{
 	        
			public void onCheckedChanged(RadioGroup arg0, int rid) {
				// TODO Auto-generated method stub
			 Log.d("radiou group", "you selected="+rid);
			 switch(rid)
			 {case R.id.radio_button0://首页
				 th.setCurrentTabByTag("TAB_HOME");
				 msgTitle.setVisibility(View.GONE);
				 break;
			 case R.id.radio_button1://信息
				 th.setCurrentTabByTag("TAB_MSG");
				 //------->
				 msgTitle.setVisibility(View.VISIBLE);
				 break;
			 case R.id.radio_button2://资料
				 th.setCurrentTabByTag("TAB_USER_INFO");
				 msgTitle.setVisibility(View.GONE);
				 break;
			 case R.id.radio_button3://搜索
				 th.setCurrentTabByTag("TAB_SEARCH");
				 msgTitle.setVisibility(View.GONE);
				 break;
			 case R.id.radio_button4://更多	
				 msgTitle.setVisibility(View.GONE);
				 th.setCurrentTabByTag("TAB_MORE");
				 
			 }
			}
			
		}
		);
	}


	
	
	
}
